#include <interface\resman.h>

#include <cstdio>

resman::resman(){

}
resman::~resman(){
    printf("Ressource manager deletion\n");
    for( vector<ressource*>::iterator i = content.begin(); i < content.end(); i++ ){
        delete (*i);
    }
}

void resman::add(ressource* res){
    content.push_back(res);
}
void resman::update(){
    ressource* r;
    for( vector<ressource*>::iterator i = content.begin(); i < content.end(); i++ ){
        if( !(*i)->update() ){
            r = (*i);
            delete r;
            content.erase(i);
        }
    }
}
void resman::erase(int i){
    delete *(content.begin()+i);
    content.erase(content.begin()+i);
}
void resman::erase(ressource* res){
    vector<ressource*>::iterator i;
    for( i = content.begin(); i < content.end() && (*i) != res; i++ ){}
    if( i != content.end() ){
        delete *i;
        content.erase(i);
    }
}
